//判断是否在微信打开
function is_weixn(){
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger") {
        return true;
    } else {
        return false;
    }
}
function GetDateT(){
    var d,s;
    d = new Date();
    s = d.getYear() + "-";             //取年份
    s = s + (d.getMonth() + 1) + "-";//取月份
    s += d.getDate() + " ";         //取日期
    s += d.getHours() + ":";       //取小时
    s += d.getMinutes() + ":";    //取分
    s += d.getSeconds();         //取秒
    return(s);
}

var urlfrom=location.href;
var id=$.cookie("MYID");
if(/\?id=[0-9a-zA-Z]+/.test(location.href)){
    id=(location.href).match(/id=[0-9a-zA-Z]+/)[0].split("=")[1];
    $.cookie("MYID",id);
}
if(id&&id!="undefined"){
    id=$.cookie("MYID");
}else{
    location.href="https://www.pulu.com/weixin/login.html";
}
//一级列表
if(document.getElementById("read1")){
    if(is_weixn()){
        document.getElementById("read1").onclick=function(){
            $.cookie("readyourcurrentIndex","");
            $.cookie("readyourscrollTop","");
            location.href="https://www.pulu.com/weixin/home.html";
        };
    }else{
        document.getElementById("read1").onclick=function(){
            $.cookie("readyourcurrentIndex","");
            $.cookie("readyourscrollTop","");
            location.href="https://www.pulu.com/home.html";
        };
    }
};
if(document.getElementById("answer1")){
    document.getElementById("answer1").onclick=function(){
        $.cookie("pulupagepage","");//清除页面ID
        $.cookie("pulupagescroll","");//当前滚动距离
        $.cookie("pulupagepage","");//当前显示页面
        $.cookie("tjcurrentIndex","");//推荐数据页码
        $.cookie("zhncurrentIndex","");//召唤你数据页码
        $.cookie("jycurrentIndex","");//经验 铺路数据页码
        location.href="https://www.pulu.com/weixin/questionlistjy.html";
    };
}
if(document.getElementById("chat1")){
    document.getElementById("chat1").onclick=function(){
        location.href="https://www.pulu.com/weixin/chatpage.html";
    };
}
if(document.getElementById("set1")){
    document.getElementById("set1").onclick=function(){
        location.href="https://www.pulu.com/weixin/setpage.html";
    };
}

if(document.getElementById("answer11")){
    document.getElementById("answer11").onclick=function(){
        $.cookie("pulupagepage","");//清除页面ID
        $.cookie("pulupagescroll","");//当前滚动距离
        $.cookie("pulupagepage","");//当前显示页面
        $.cookie("tjcurrentIndex","");//推荐数据页码
        $.cookie("zhncurrentIndex","");//召唤你数据页码
        $.cookie("jycurrentIndex","");//经验 铺路数据页码
        location.href="questionlist.html";
    };
}
if(document.getElementById("chat11")){
    document.getElementById("chat11").onclick=function(){
        location.href="chatpage.html";
    };
}
if(document.getElementById("set11")){
    document.getElementById("set11").onclick=function(){
        location.href="setpage.html";
    };
}
//二级列表
if(document.getElementById("yours2")){
    document.getElementById("yours2").onclick=function(){
        $.cookie("readyourcurrentIndex","");
        $.cookie("readyourscrollTop","");
        location.href="https://www.pulu.com/weixin/home.html";
    };
}
if(document.getElementById("zhzx2")){
    document.getElementById("zhzx2").onclick=function(){
        location.href="https://www.pulu.com/weixin/zonghenews.html";
    };
}
if(document.getElementById("hyxw2")){
    document.getElementById("hyxw2").onclick=function(){
        location.href="https://www.pulu.com/weixin/zonghenews1.html";
    };
}
if(document.getElementById("xq2")){
    document.getElementById("xq2").onclick=function(){
        location.href="https://www.pulu.com/weixin/zonghenews2.html";
    };
}
if(document.getElementById("question1")){
    document.getElementById("question1").onclick=function(){
        location.href="https://www.pulu.com/weixin/questionlisttw.html";
    };
}
//高额经验跳转
if(document.getElementById("exphei")){
    document.getElementById("exphei").onclick=function(){
        location.href="https://www.pulu.com/weixin/questionlistjyg.html";
    }
}
//搜索框
if(document.getElementById("gotosearch")){
    if(!location.href.match(/search/)){
        document.getElementById("gotosearch").onclick=function(){
            location.href="search.html?searchKey=";
        }
    }else{
        document.getElementById("gotosearch").onclick=function(){
            var word=document.getElementById("searchinput").value;
            if(word){
                if(word.match(/^\s+$/g)){
                    console.log("没有填信息")

                }else{
                    location.href="searchdetail.html?searchKey="+word;
                }
            }
        }
    }
}
//放大镜搜索按钮
if(document.querySelector(".header_action_buttons a.search")){
    document.querySelector(".header_action_buttons a.search").onclick=function(){
        location.href="search.html?searchKey=";
    };
}
//PC点击搜索框进行跳转
if(document.getElementById("headersearchdiv")){
    document.getElementById("headersearchdiv").onclick=function(){
        location.href="search.html?searchKey=";
    };
}
if(window.screen.availWidth>1000){
    console.log((window.screen.availWidth-1000)/2-7);
    $(".rightnav").css("right",(window.screen.availWidth-1000)/2-7+"px");
    $(".rightnav1").css("right",(window.screen.availWidth-1000)/2-7+"px");
    $(".rightnav2").css("right",(window.screen.availWidth-1000)/2-7+"px");
}